DXL script using filter crashes

Hello

I'm making a slight modification on an existing DXL script which uses filtering on attributes. My task was to add another filter so that it selects only that data that excludes all those objects with that particular value. So I came up with this compound filter where I was "AND"ing this new filter to the original one, but strangely this works fine for few modules and crashes for another module(which is where it is actually required to work!). Initially it seemed like a module problem, but then I tried only the compound filter on the module and that had worked fine. There is this error after it crashes: +Exception_Access_Violation in module : std:basic_string<char,std::char_traits<char>,std::allocator<char>>::_Tidy()+0010byte(s)+
I believe it could be because of mismatch during assigning values to variable.

Initially I tried the following filter which caused DOORS to crash everytime I run it :


void setFiltering(){

Module m;

string attName = get (choiceFrom); // obtains both choiceFrom and choiceWhat from a choice() dialog box.
string prodName = get(choiceWhat);
AttrDef ad = null;
AttrType selAttr = null;
int i;
Filter f = null;
delete editList;
editList = create;
bool isFiltered = false;
int pocet = 0;
_Filter reqstatus = attribute VALUE_ATTR_NAME!= "Obsolete"_ // Added by me
for m in moduleList do {

current = m;
pocet++;
int attSize;
ad = find(m,attName);
selAttr = find (m, VALUE_ATTRIBUTE_NAME);
if (!null ad){
Filter f2 = includes (attribute attName,prodName)
f = reqstatus && f2;


Running the above always backtraced to the setfiltering() call function; and as it had worked fine earlier, it was a problem with the small addition I made. So I replaced the above filter "reqstatus" definition with the following:
Filter reqstatus = excludes(attribute VALUE_ATTR_NAME, "Obsolete")

This did not crash DOORS but still doesn't work with this error: attribute must be multi valued
Also, the attribute VALUE_ATTR_NAME(which is a string variable), is a single-valued attribute with 4values.

I also find it strange that only for few modules it doesn't work and I have no clue what other functions can be used for this. I'm only few months old at DXL scripting, and need a resolution soon. Please advise.
Thanks!
SystemAdmin - Thu Nov 08 03:10:26 EST 2012

Re: DXL script using filter crashes
Johnny_P - Thu Nov 08 03:36:15 EST 2012

Hi,

it seems, that the attribute you're filtering is a multi valued enumeration in some modules and a single choice enumeration in other modules.
If an atribute is not multivalued, you can't use the includes or excludes filters.

Try something like this:

AttrDef myAd = find(m, VALUE_ATTR_NAME)
Filter reqstatus = null
 
if (myAd.multi) {
    reqstatus = excludes(attribute VALUE_ATTR_NAME, "Obsolete")
}
else {
        reqstatus = attribute VALUE_ATTR_NAME != "Obsolete"
}

 


Regards,
Johnny

 

Re: DXL script using filter crashes
SystemAdmin - Thu Nov 08 05:46:47 EST 2012

Johnny_P - Thu Nov 08 03:36:15 EST 2012

Hi,

it seems, that the attribute you're filtering is a multi valued enumeration in some modules and a single choice enumeration in other modules.
If an atribute is not multivalued, you can't use the includes or excludes filters.

Try something like this:

AttrDef myAd = find(m, VALUE_ATTR_NAME)
Filter reqstatus = null
 
if (myAd.multi) {
    reqstatus = excludes(attribute VALUE_ATTR_NAME, "Obsolete")
}
else {
        reqstatus = attribute VALUE_ATTR_NAME != "Obsolete"
}

 


Regards,
Johnny

 

Hi Johnny,

Thanks a lot for that explanation. That explains the ambiguous results I was getting. And that script snippet solves the issue too :)

--Sindhu

Re: DXL script using filter crashes
llandale - Thu Nov 08 15:31:49 EST 2012

I'm fuzzy on filtering and the following is incomplete, but should help move you along.
  • filtering "excludes" is for multi-enumerated attributes. I think you want:
    • Filter f2 = !contains(attribute(name), value) // "contents" instead of "contains"??
  • IIRC a "Filter" is applicable to the "current" module. While you correctly set current = m I'm guessing that you will need to re-calculate Filter reqStatus each time you switch modules.

-Louie